﻿using System.Linq;
using IceDog.DNF.Program.Poker.Core;

namespace IceDog.DNF.Program.Poker.Client.Cli
{
    /// <summary>
    /// 玩家对象类
    /// </summary>
    public class Player
    {
        /// <summary>
        /// 玩家名字
        /// </summary>
        public string Name { get; }
        /// <summary>
        /// 手牌
        /// </summary>
        public CardList PlayHand { get; }

        /// <summary>
        /// 禁用默认构造函数
        /// </summary>
        private Player() { }

        /// <summary>
        /// 自定义构造函数
        /// </summary>
        /// <param name="name">玩家姓名</param>
        public Player(string name)
        {
            Name = name;
            PlayHand = new CardList();
        }
        /// <summary>
        /// 胜利条件，玩家手牌所有花色相同即胜利
        /// </summary>
        /// <returns></returns>
        public bool HasWin()
        {
            Suit match = PlayHand[0].Suit;
            var win = PlayHand.All(x => x.Suit == match);
            return win;
        }
    }
}
